﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using FinPlusCompCore;
using QLNet;
using p = FinPlusCompQuant.QLConvParser;

namespace FinPlusCompQuant
{
    public class YieldCurve : FinPlusComponent
    {
        public PiecewiseYieldCurve PiecewiseYieldCurve { get; private set; }
        public SwapEngine SwapEngine { get; private set; }

        //construct
        public YieldCurve(Market market, string name, string discountCurveName, DateTime settlementDate, string[] rates, string dayCount, string holidays, double tolerance = 1.0e-15)
        {
            Id = name;
            var calendar = p.Calendar(holidays);
            var helpers = market.GetRateHelpers(rates);

            PiecewiseYieldCurve = new PiecewiseYieldCurve<Discount, LogLinear>(settlementDate, helpers, p.DayCount(dayCount), new List<Handle<Quote>>(), new List<Date>(), tolerance);
            market.SetCurve(name, PiecewiseYieldCurve);
            SwapEngine = new SwapEngine(market, name, discountCurveName == "" ? name : discountCurveName);
        }
    }
}
